<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"          			
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      >
    <ui:composition template="TaskProLayout.xhtml">
        <ui:define name="content">
            <div class="Post">
                <h:form>
               <h:panelGrid columns="2">
                <p:commandLink  value="Back" action="assignTaskKantor" ajax="False"/>
                </h:panelGrid> 
                </h:form>
            </div>
                    <div class="Post">
                  </div>
            <h:form id="taskConfirmForm">   
                <div class="Post">
                     <h:panelGrid columns="2">
                <h:outputText value="Notify users:" />
                <p:selectBooleanButton value="#{kantorTaskBean.notifyUsers}" onLabel="Yes" offLabel="No" />  
            </h:panelGrid>  
                    <p:notificationBar position="top" effect="slide"  widgetVar="bar" styleClass="top">  
                        <h:outputText value="System start with assignment your task to student thi action could take a few second or minutes depend on number of users." style="color:#FFCC00;font-size:36px;" />  
                    </p:notificationBar>  
                    <p:dataTable var="tasks" value="#{kantorTaskBean.finalAssignments}" 
                                 emptyMessage="No tasks were selected"
                                 rowKey="#{tasks.subject.code}">  
                        <f:facet name="header">  
                            <h:outputText value="Selected Task" />
                        </f:facet>  
                        <p:column headerText="Label" style="width:150px">   
                            <h:outputText value="#{tasks.template.name}" >                    
                                  <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column>  
                        <p:column headerText="Description" style="width:150px">                                    
                            <h:outputText value="#{tasks.template.description}" >
                                 <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Deadline" style="width:150px">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{tasks.deadline}" >
                                        <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                                    </h:outputText>
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:calendar required="true" value="#{tasks.deadline}" pattern="dd.MM.yyyy HH:mm"  timeZone="Europe/Prague" />   
                                </f:facet>  
                            </p:cellEditor>  
                        </p:column>  
                           <p:column headerText="Start time" style="width:150px">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{tasks.dateOfStart}" >
                                        <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                                    </h:outputText>
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:calendar required="true" value="#{tasks.dateOfStart}" pattern="dd.MM.yyyy HH:mm"  timeZone="Europe/Prague" />   
                                </f:facet>  
                            </p:cellEditor>  
                        </p:column>  
                        <p:column headerText="Points" style="width:50px">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{tasks.maxScore}" />               
                                </f:facet>  
                                <f:facet name="input" >  
                                    <h:inputText value="#{tasks.maxScore}" style="width:50px" />
                                </f:facet>  
                            </p:cellEditor>  
                        </p:column>  
                        <p:column headerText="Options">  
                            <p:rowEditor />  
                        </p:column> 
                        <f:facet name="footer" >
                            <h:outputText value=" " />
                        </f:facet>
                    </p:dataTable>
                </div>
                <div class="Post">
                    <p:dataTable var="student" value="#{kantorTaskBean.kantorStudents}"
                                 emptyMessage="No students were selected" rendered="#{kantorTaskBean.isStudentTask}"
                                 rowKey="#{student.login}">  
                        <f:facet name="header">  
                            <h:outputText value="Selected students" />
                        </f:facet>  
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Name" />  
                            </f:facet>  
                            <h:outputText value="#{student.name}" />  
                        </p:column>  

                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Surname" />  
                            </f:facet>  
                            <h:outputText value="#{student.surname}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Login" />  
                            </f:facet>  
                            <h:outputText value="#{student.login}" >
                                <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="E-mail" />  
                            </f:facet>  
                            <h:outputText value="#{student.email}" >
                                <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column> 
                        <f:facet name="footer" >
                            <h:outputText value=" " />
                        </f:facet>
                    </p:dataTable>                      
                    <p:dataTable var="group" value="#{kantorTaskBean.kantorGroups}"
                                 emptyMessage="No students were selected" rendered="#{kantorTaskBean.isGroupTask}"
                                 rowKey="#{group.id}">  
                        <f:facet name="header">  
                            <h:outputText value="Selected group" />
                        </f:facet>  
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Name" />  
                            </f:facet>  
                            <h:outputText value="#{group.code}" />  
                        </p:column>   
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Subject" />  
                            </f:facet>  
                            <h:outputText value="#{group.subject.code}" />  
                        </p:column>   
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Start time" />  
                            </f:facet>  
                            <h:outputText value="#{group.startTime}" >
                                <f:convertDateTime type="time" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                        </p:column>  
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Stop time" />  
                            </f:facet>  
                            <h:outputText value="#{group.stopTime}" >
                                <f:convertDateTime type="time" timeZone="Europe/Prague"></f:convertDateTime>
                            </h:outputText>
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Date of teach" />  
                            </f:facet>  
                            <h:outputText value="#{group.dayOfTeach}" />  
                        </p:column> 
                        <f:facet name="footer" >
                            <h:outputText value=" " />
                        </f:facet>
                    </p:dataTable>  
                    <p:dataTable var="team" value="#{kantorTaskBean.kantorTeam}"
                                 emptyMessage="No students were selected" rendered="#{kantorTaskBean.isTeamTask}"
                                 rowKey="#{team.name}">  
                        <f:facet name="header">  
                            <h:outputText value="Selected Team" />
                        </f:facet>  
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Name" />  
                            </f:facet>  
                            <h:outputText value="#{team.name}" />  
                        </p:column>  
                        <p:column>  
                            <f:facet name="header">  
                                <h:outputText value="Subject"/>  
                            </f:facet>  
                            <h:outputText value="#{team.group.code}" />  
                        </p:column>
                        <f:facet name="footer" >
                            <h:outputText value=" " />
                        </f:facet>
                    </p:dataTable>                    
                    <p:commandButton ajax="false" value="Assign" update="messageForm:msgs" onclick="bar.show()" oncomplete="bar.hide()"  action="#{kantorTaskBean.confirmAssignment()}" />
                </div> 
            </h:form>
        </ui:define>
    </ui:composition>
</html>